package com.stone.boot.pipeline.domain.vo;

import lombok.Data;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * 流程器VO
 *
 * @author Mr_wenpan@163.com 2021/8/4 5:32 下午
 */
@Data
public class PipelineVO {

    /**
     * 流程器编码
     */
    private String pipelineCode;
    /**
     * 开始节点（值为开始节点的bean的名称）
     */
    private String startAction;
    /**
     * 结束节点（值为结束节点的bean的名称）
     */
    private String endAction;
    /**
     * 保存所有节点（值为要执行的节点的名称集合）
     */
    private final Set<String> allNodeAction;
    /**
     * 该流程的所有节点，通过 [ 当前节点bean的名称 + , + SUCCESS / FAILED ] 组织
     */
    private final Map<String, PipelineNodeVO> pipelineNodes;

    // ======================================非流程器运行时必要参数=======================================

    /**
     * 是否启用
     */
    private Integer isEnable;
    /**
     * 流程器描述
     */
    private String description;

    public PipelineVO() {
        allNodeAction = new HashSet<>();
        pipelineNodes = new HashMap<>();
    }

    // redis中存放的数据结构如下
    // ========================================================================================================
    // {
    //    "allNodeAction":[
    //        "owOrderGenerateErrorNode",
    //        "owOrderGenerateBuildNode",
    //        "owOrderGenerateSaveNode",
    //        "owOrderGenerateValidateNode",
    //        "owOrderGenerateConsignmentNode"
    //    ],
    //    "pipelineCode":"OW_ORDER_GENERATE",
    //    "pipelineNodes":{
    //        "owOrderGenerateSaveNode,SUCCESS":{
    //            "curAction":"owOrderGenerateSaveNode",
    //            "nextAction":"owOrderGenerateConsignmentNode",
    //            "nodeId":59,
    //            "strategyType":"SUCCESS"
    //        },
    //        "owOrderGenerateSaveNode,FAILED":{
    //            "curAction":"owOrderGenerateSaveNode",
    //            "nextAction":"owOrderGenerateErrorNode",
    //            "nodeId":60,
    //            "strategyType":"FAILED"
    //        }
    //    },
    //    "startAction":"owOrderGenerateValidateNode"
    //}
    // ========================================================================================================
}